﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Chapter19.Example03
{
    public partial class ResultPage : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                var selectedEvent = (PreviousPage.FindControl("dropDownListEvents") as DropDownList).SelectedValue;
                var firstName = (PreviousPage.FindControl("textFirstName") as TextBox).Text;
                var lastName = (PreviousPage.FindControl("textLastName") as TextBox).Text;
                var email = (PreviousPage.FindControl("textEmail") as TextBox).Text;
                labelResult.Text = string.Format("{0} {1} 选择的事件是 {2}.", firstName, lastName, selectedEvent);
            }
            catch
            {
                labelResult.Text = "源页面必须包含姓名和邮箱控件";
            }
        }
    }
}